/*
 * vector_test_gtest.h
 *
 *  Created on: Nov 29, 2012
 *      Author: m
 */

#include <gtest/gtest.h>


#include <gtest/gtest.h>
#include <vector>
#include <cstring>

using physical::byte;
using physical::VariableStringSerializer;
using std::string;

class VectorTestFixture : public ::testing::Test
{
public:
    VectorTestFixture()
    {
        // initialization code here
    }

    void SetUp()
    {
        // code here will execute just before the test ensues
    }

    void TearDown()
    {
        // code here will be called just after the test completes
        // ok to through exceptions from here if need be
    }

    ~VectorTestFixture()
    {
        // cleanup any pending stuff, but no exceptions allowed
    }

    // put in any custom data members that you need

};

TEST_F ( VectorTestFixture, fromArray )
{
    std::vector<char> myVector;
    char myArray[10];

    for ( int i = 0; i<10; i++ )
    {
        myArray[i] = i+100;
    }

    ASSERT_TRUE( myVector.empty() );

    myVector.assign( myArray, myArray+10 );

    ASSERT_EQ( memcmp( myArray, &myVector.front(), 10), 0 );
}

TEST_F ( VectorTestFixture, toArray )
{
    std::vector<char> myVector(10);
    char myArray[10];

    for ( int i = 0; i<10; i++ )
    {
        myVector[i] = i+100;
    }

    memcpy( myArray, &myVector.front(), myVector.size() );

    ASSERT_EQ( memcmp( myArray, &myVector.front(), 10), 0 );
}
